package com.zjq.designpatterns.behaviors.observer.code;/*
 * 版权信息: 北京千⾥马网信科技有限公司</br>
 * Copyright ©2008-2018. All rights reserved. 京ICP备16007318号
 */

import java.util.Observable;
import java.util.Observer;

/**
 * 观察的是课程，问题属于课程
 * @author jessie
 * @version 1.0
 * @date 2021/1/27
 */
public class Teacher implements Observer {
    private String teacherName;

    public Teacher(String teacherName) {
        this.teacherName = teacherName;
    }

    /**
     * @param o 被观察的对象
     * @param arg 通过notifyObservers传递的参数
     */
    @Override
    public void update(Observable o, Object arg) {
        Course course = (Course) o; //被观察的对象
        Question question = (Question) arg;
        System.out.println(teacherName+"老师的"+course.getCourseName()
                +"课程接收到的一个"+question.getUserName()+"提交的问答："+question.getQuestionContent());
    }
}
